﻿@model List<SiteNavDTO>
@{
    ViewBag.Title = "菜单管理";
}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> 菜单管理 <a class="btn btn-success radius r btn-refresh" style="line-height:1.6em;margin-top:3px" href="javascript:;" onclick="javascript: location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray"> <span class="l"> <a href="javascript:;" onclick="batch_del()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a class="btn btn-primary radius" href="javascript:;" onclick="layer_show('添加菜单', '/WebAdmin/SiteNav/Add', '800')"><i class="Hui-iconfont">&#xe600;</i> 添加菜单</a> </span> <span class="r">共有数据：<strong>@Model.Count()</strong> 条</span> </div>
    <form id="formList">
        <table class="table table-border table-bg table-bordered table-hover">
            <thead>
                <tr>
                    <th scope="col" colspan="10">菜单列表</th>
                </tr>
                <tr class="text-c">
                    <th width="25"><input type="checkbox" value="" name=""></th>
                    <th width="40">ID</th>
                    <th>菜单名称</th>
                    <th>菜单地址</th>
                    <th>菜单级别</th>
                    <th width="70">功能分类</th>
                    <th width="70">是否显示</th>
                    <th width="40">排序</th>
                    <th width="70">操作</th>
                    <th width="70">内容编辑</th>
                </tr>
            </thead>
            <tbody>
                @{
                    foreach (var siteNav in Model)
                    {
                        <tr class="text-c trLevevl@(siteNav.NavLevel)">
                            <td><input type="checkbox" value="@siteNav.Id" name="selectdIds"></td>
                            <td>@siteNav.Id</td>
                            <td class="text-l">
                                @for (int i = 0; i < siteNav.NavLevel; i++)
                                {
                                @:|-
                                }
                                @siteNav.NavName
                            </td>
                            <td>@siteNav.NavUrl</td>
                            <td>@siteNav.NavLevel</td>
                            <td>@siteNav.FunName</td>
                            <td>
                                @if (siteNav.IsShow)
                                {
                                    <i class="Hui-iconfont c-success">&#xe6a7;</i>
                                }
                                else
                                {
                                    <i class="Hui-iconfont c-error">&#xe6a6;</i>
                                }
                            </td>
                            <td>@siteNav.Sort</td>
                            <td class="f-14">
                                <a title="编辑" href="javascript:;" onclick="layer_show('编辑菜单', '/WebAdmin/SiteNav/Edit?id=@siteNav.Id', '800')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                                <a title="删除" href="javascript:;" onclick="del(this,@siteNav.Id)" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                            </td>
                            <td>
                                @if (!string.IsNullOrEmpty(siteNav.CtrlUrl))
                                {
                                    <a title="内容编辑" href="javascript:;" onclick="layer_full('【@(siteNav.NavName)】栏目维护', '@(siteNav.CtrlUrl)?id=@siteNav.Id')" style="text-decoration:none"><i class="Hui-iconfont">&#xe60c;</i></a>
                                }
                            </td>
                        </tr>
                    }
                }
            </tbody>
        </table>
    </form>
</div>
@section FooterScript
{
    <script type="text/javascript">
        //弹出层全屏
        function layer_full(title, url) {
            var index = layer.open({
                type: 2,
                title: title,
                content: url
            });
            layer.full(index);
        }

        /*管理员-角色-批量删除*/
        function batch_del() {
            layer.confirm("确认要批量删除吗？", function () {
                var formData = $("#formList").serializeArray();
                $.ajax({
                    url: "/WebAdmin/SiteNav/BatchDelete",
                    type: "post",
                    data: formData,
                    dataType: "json",
                    success: function (res) {
                        if (res.status == "ok") {
                            layer.msg('已批量删除!', { icon: 1, time: 2000 }, function () {
                                $(".btn-refresh").click();
                            });
                        } else if (res.status == "redirect") {
                            location.href = res.data;
                        } else if (res.status == "error") {
                            layer.msg(res.errorMsg, { icon: 2, time: 1000 });
                        } else {
                            layer.msg("批量删除失败", { icon: 2, time: 1000 });
                        }
                    },
                    error: function () {
                        layer.msg('网络出错!', { icon: 2, time: 2000 });
                    }
                });
            });
        }

        /*管理员-角色-删除*/
        function del(obj, id) {
            layer.confirm('确认要删除吗？', function (index) {
                $.ajax({
                    type: 'POST',
                    url: '/WebAdmin/SiteNav/Delete',
                    data: { id: id },
                    dataType: 'json',
                    success: function (res) {
                        if (res.status == "ok") {
                            layer.msg('已删除!', { icon: 1, time: 2000 }, function () {
                                $(".btn-refresh").click();
                            });
                        } else if (res.status == "redirect") {
                            location.href = res.data;
                        } else if (res.status == "error") {
                            layer.msg(res.errorMsg, { icon: 2, time: 1000 });
                        } else {
                            layer.msg("删除失败", { icon: 2, time: 1000 });
                        }
                    },
                    error: function (data) {
                        layer.msg('网络出错!', { icon: 2, time: 2000 });
                    },
                });
            });
        }
    </script>
}




